package com.iterator.self;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class OutPutImpl {

    private List<Company> companyList;

    public OutPutImpl(List<Company> companyList) {
        this.companyList = companyList;
    }

    public void printCompany(){
        Iterator<Company> companyIterator = companyList.iterator();
        while (companyIterator.hasNext()){
            Company company = companyIterator.next();
            System.out.println("----公司的名字是----"+company.getName());
            printSector(company.getIterator());
        }
    }

    private void printSector(Iterator iterator) {
        while (iterator.hasNext()){
            Sector sector = (Sector) iterator.next();
            System.out.println("----部门的名字是----"+sector.getName());
        }
    }
}
